import Vue from 'vue'
import VueRouter from 'vue-router'
import home from '../components/Home/Home.vue'
import managerHome from "@/components/Manager/managerHome";
import notFound from "@/components/Login/404";
import login from "@/components/Login/login";
import register from "@/components/Login/register";
import backHome from "@/components/Page/backHome";
import goods from "@/components/Page/goods";
import map from "@/components/Page/map";
import Index from "@/components/Page/index";
import news from "@/components/Page/news";
import prevention from "@/components/Page/prevention";
import story from "@/components/Page/story";
import vaccineApply from "@/components/Page/vaccineApply";
import InformToUser from "@/components/Page/InformToUser";
import personal from "@/components/User/personal";
import personalCenter from "@/components/User/personalCenter";
import healthCode from "@/components/User/healthCode";
import application from "@/components/User/application";
import MyTemperature from "@/components/User/MyTemperature";
import KnowledgeDetail from "@/components/Page/KnowledgeDetail";
import ManagerLogin from "@/components/Login/ManagerLogin";
import managerIndex from "@/components/Manager/managerIndex";
import ManagingPeople from "@/components/Manager/ManagingPeople";
import yisiPeople from "@/components/Manager/yisiPeople";
import GoodsManager from "@/components/Manager/GoodsManager";
import VaccineManager from "@/components/Manager/VaccineManager";
import newsManage from "@/components/Manager/newsManage";
import newsDelete from "@/components/Manager/newsDelete";
import manageManager from "@/components/Manager/manageManager";
import preventionManage from "@/components/Manager/preventionManage";




import muchCar from "@/components/muchCar";
import ceshi from "@/components/ceshi";


Vue.use(VueRouter)

const routes = [
    /*{path: '/', redirect: '/EPS'},
    {path: '/EPS', component: home},*/
    {
        path: '/',
        component: home,
        redirect: "/ESP"
    },

    {
        path: '/index',
        component: home,
        redirect: "/ESP",
        children: [
            {path: "/ESP", component: Index},
            {path: "/community/backHome", component: backHome},
            {path: "/community/goods", component: goods},
            {path: "/map", component: map},
            {path: "/news", component: news},
            {path: "/prevent/prevention", component: prevention},
            {path: "/prevent/story", component: story},
            {path: "/community/vaccineApply", component: vaccineApply},
            {path: "/InformToUser", component: InformToUser},
            {
                path: '/personal', component: personal,
                children: [{path: '/personal', component: personalCenter},
                    {path: '/healthCode', component: healthCode},
                    {path: '/MyTemperature', component: MyTemperature},
                    {path: '/application', component: application},
                    {path: '/ceshi', component: ceshi},]
            },
        ]
    },

    {path: "/KnowledgeDetail", component: KnowledgeDetail},


    {
        path: '/managerHome',
        component: managerHome,
        children: [
            {path: "/managerHome", component: Index},
            {path: "/managerHome/community/backHome", component: backHome},
            {path: "/managerHome/community/goods", component: goods},
            {path: "/managerHome/map", component: map},
            {path: "/managerHome/news", component: news},
            {path: "/managerHome/prevent/prevention", component: prevention},
            {path: "/managerHome/prevent/story", component: story},
            {path: "/managerHome/community/vaccineApply", component: vaccineApply},
            {path: "/managerHome/KnowledgeDetail", component: KnowledgeDetail},
            {path: '/managerIndex', component: managerIndex},
            {path: '/ManagingPeople', component: ManagingPeople},
            {path: '/managerHome/GoodsManager', component: GoodsManager},
            {path: '/managerHome/VaccineManager', component: VaccineManager},
            {path: '/managerHomer/newsManage',component: newsManage},
            {path: '/managerHomer/newsDelete',component: newsDelete},
            {path: '/managerHomer/manageManager',component: manageManager},
            {path: '/managerHomer/preventionManage',component: preventionManage},
        ]
    },

    {path: "/yisiPeople", component: yisiPeople},

    {
        path: '/login',
        component: login
    },
    {
        path: '/ManagerLogin',
        component: ManagerLogin
    },
    {
        path: '/muchCar',
        component: muchCar
    },
    {
        path: '/register',
        component: register
    },
    {
        path: "/404",
        name: "notFound",
        component: notFound
    }, {
        path: "*", // 此处需特别注意置于最底部
        redirect: "/404"
    },
]
const router = new VueRouter({
    routes
})

// 导航守卫
// 使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆
/*router.beforeEach((to, from, next) => {
    if (to.path === '/login'||to.path==='/ESP'||to.path==='/register'||to.path==='/404') {
        next();
    } else {
        /!*let token = localStorage.getItem('Authorization');*!/
        let token = window.sessionStorage.getItem('token')

        if (token === null || token === '') {
            next('/login');
        } else {
            next();
        }
    }
});*/

export default router
